package com.fc.mall.portal.controller;

import com.fc.mall.base.object.Result;
import com.fc.mall.model.PmsSkuStock;
import com.fc.mall.portal.dto.SkuGroup;
import com.fc.mall.portal.service.SkuStockService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商品SKU管理
 * Created by Howard.Miao 2019/04/15
 */
@Controller
@Api(tags = "PmsSkuStockController", description = "sku商品库存管理")
@RequestMapping("/sku")
public class SkuStockController {

    @Autowired
    private SkuStockService skuStockService;

    @ApiOperation("根据商品编号及编号模糊搜索sku库存")
    @RequestMapping(value = "/{pid}", method = RequestMethod.GET)
    @ResponseBody
    public Object getList(@PathVariable Long pid, @RequestParam(value = "keyword",required = false) String keyword) {
        List<PmsSkuStock> skuStockList = skuStockService.getList(pid, keyword);
        return Result.success(skuStockList);
    }

    @ApiOperation("查询商品Sku列表")
    @RequestMapping(value = "/list/{pid}", method = RequestMethod.GET)
    @ResponseBody
    public Result handleGetSkuByProduct(@PathVariable Long pid) {

        List<SkuGroup> skuGroupList = skuStockService.getSkuGroupByProduct(pid);
        return Result.success(skuGroupList);
    }



}
